package com.jlp.source.manager;

import com.jlp.source.domain.User;
import com.jlp.source.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author lingpeng.jiang
 * @create 2022-01-09 20:25
 * @Description //TODO
 **/
@Component
public class UserManager {

    @Autowired
    private UserService userService;

    @Transactional(rollbackFor = Exception.class)
    public String insertUser(){

        User userMysql = new User();
        userMysql.setUserId(2L);
        userMysql.setUsername("mysql");
        userMysql.setAge(19);


        User userTidb = new User();
        userTidb.setUserId(2L);
        userTidb.setUsername("tidb2");
        userTidb.setAge(20);

        userService.updateMysqlUserById(userMysql);
        userService.updateTidbUserById(userTidb);
        return "success";

    }


}
